<?php

namespace app\exam\validate;

use think\Validate;

/**
 * 专项练习验证
 */
class Special extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'module_id'   => 'require|number',
        'category'    => 'require|number',
        'title'       => 'require',
        'special_id'  => 'require|number',
        'topic_id'    => 'require|/^[\d,]+$/',
        'topic_level' => 'require|in:1,2',
        'is_right'    => 'require|in:0,1',

    ];

    protected $field = [
        'module_id'   => '版块',
        'category'    => '分类',
        'title'       => '名称',
        'special_id'  => '专项',
        'topic_id'    => '试题',
        'topic_level' => '试题层级',
        'is_right'    => '试题答案结果',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'special_list'   => ['module_id'],
        'special_search' => ['module_id', 'category', 'title'],
        'special_base'   => ['special_id'],
        'special_topic'  => ['topic_id'],
        'special_answer' => ['topic_id', 'is_right'],
        'clear'          => ['special_id'],
    ];

}
